<!DOCTYPE HTML>
<html>
    <head>
                <link href="stylesheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <h1 align = "center"><font face = 'Edwardian Script ITC'>View Contacts</font></h1>
        <form method = "POST" action = "admin_main_menu.php">
            <input value = "Home" type = "submit" style = "float: left;">
        </form><br><br>
        <?php
         /****************************************/
	   /*************DATABASE STUFF**************/
		    $username = 'root';
			$pw = '';
			$con = mysqli_connect("localhost", $username, $pw, 'milestone');
		
			if (mysqli_connect_errno()) 
			{
				echo "Failed to connect to MySQL: " . mysqli_connect_error();
			}
		   
			 //set time to the central time zone
			if ( !date_default_timezone_set ( 'America/Chicago' ) )
			{
				echo "could not set time zone!";
			}
			
			$date = new DateTime();
			$datetime_string = date_format($date, 'Y-m-d');

		/*****************************************/
       
        
        $querystring = "SELECT FirstName,LastName,Phone,isAdmin,email FROM users WHERE isAdmin = 0"; //select non admin users
        // and get contact information for display

        $result = mysqli_query($con, $querystring);//pass sql query to phpmyadmin
        echo "<table border = 1 width = 100%>";
        echo "<tr>";
        echo "<td width = 13%><b>First Name</b></td><td width = 13%><b>Last Name  </b></td><td width = 13%><b>Phone Number </b>             </td><td width = 13%><b>Email    </b></td>";
        echo "</tr>";

        while($row = mysqli_fetch_assoc($result)) //go through all rows where condition is true and get info
        {
        
        $firstname = $row['FirstName'];
        $lastname = $row['LastName'];
        $phoneNumber = $row['Phone'];
        $email =  $row['email'];
            
        //print contact information   
        echo "<tr>";
        echo "<td>" . $firstname . "    " . "</td>";
        echo "<td>" . $lastname . "    " . "</td>";
        echo "<td>" . $phoneNumber . "    " . "</td>";
        echo "<td>" . $email . "    " . "</td>";
        echo "</tr>";
            
        }
        echo "</tr>";
        echo "</table>";
			
        ?>
    </body>
</html>